package com.xiaoyg.lock;

public class SyncUninterruptible {

    //定义一个runnable

    public static Object obj = new Object();

    public static void main(String[] args) throws InterruptedException {
        Runnable runnable = ()->{
          synchronized (obj){
              System.out.println(Thread.currentThread().getName()+""+"进入同步代码块");
              try {
                  Thread.sleep(888888);
              } catch (InterruptedException e) {
                  e.printStackTrace();
              }
          }
        };

        Thread t1 = new Thread(runnable);
        t1.start();
        Thread.sleep(1000);

        Thread t2 = new Thread(runnable);
        t2.start();

        System.out.println("停止线程前");
        t2.interrupt();
        System.out.println("停止线程后");

        System.out.println(t1.getState());
        System.out.println(t2.getState());


    }

}
